
const shouldUseTransition = !/transition=none/.test(location.href)
const app = {
  state: {
    isLoading: false,
    scrollTop: 0,
    direction: shouldUseTransition ? 'foward' : '',
    isOnQuanUBase: false, // 是否在全友应用基座上
    statusBarHeight: 0 // 状态栏高度
  },
  mutations: {
    updatePosition(state, payload) {
      state.scrollTop = payload.top
    },
    updateLoadingStatus(state, payload) {
      state.isLoading = payload.isLoading
    },
    updateDirection(state, payload) {
      if (!shouldUseTransition) {
        return
      }
      state.direction = payload.direction
    },
    updateStatusBarHeight(state, height) {
      state.statusBarHeight = height || 20
    }

  },
  actions: {
    updatePosition({ commit }, top) {
      commit({ type: 'updatePosition', top: top })
    }
  }
}

export default app
